<template>
	<view class="mine">
		<image style="width: 100%;" src="/static/img_my.png" mode="widthFix"></image>
		<view class="head">
			<image style="width: 120rpx;" src="../../static/avatar.png" mode="widthFix"></image>
			<view class="head_con">
				<view class="head_name" @click="handleAuth">{{info.name || '点击去授权'}}</view>
				<view class="head_tips">凭信用抵押金快捷租房</view>
			</view>
		</view>
		<!-- 工具 -->
		<view class="setup">
			<view class="setup_title">工具</view>
			<view class="setup_li">
				<view class="setup_item" @click="handleLianxi">
					<image src="../../static/kefu.png" mode="widthFix"></image>
					<view class="">客服服务</view>
				</view>
				<view class="setup_item" @click="handleNext('/pages/my/real')">
					<image src="../../static/shiming.png" mode="widthFix"></image>
					<view class="">实名认证</view>
				</view>
				<view class="setup_item" @click="handleLogin">
					<image src="../../static/tuichu.png" mode="widthFix"></image>
					<view class="">退出登录</view>
				</view>
			</view>
		</view>
		<view class="banner">
			<image style="width: 100%;" src="/static/banner.png" mode="widthFix"></image>
		</view>
		<view class="num">版本号：0.0.1</view>
	</view>
</template>

<script>
	import request from '@/utils/request.js';
	export default {
		data() {
			return {
				info:{}
			}
		},
		async onLoad(){
			  try {
			  	const response = await request('/v1/user', 'GET', {},'info');
			  	if (response) {
					this.info=response.body
			  	}
			  
			  } catch (error) {
			  	console.error('请求失败:', error);
			  }
		},
		methods: {
			handleNext(url){
				// console.log(url);
				if(url=='/pages/my/real'){
					if(this.info.check!=undefined){
						uni.showToast({
							icon:"none",
							title:"已实名认证"
						})
					}else{
						uni.navigateTo({
							url:url
						})
					}
				}else{
					uni.navigateTo({
						url:url
					})
				}
				
			},
			handleLianxi(){
				uni.showModal({
					title: '联系我们',
					content: '18687405643',
					cancelColor:'#000000',
					confirmColor:'#FF8841',
					success: function (res) {
						if (res.confirm) {
							uni.makePhoneCall({
								phoneNumber: '18687405643',
							});
						} else if (res.cancel) {
							
						}
					}
				});
			},
			//没登录去登录
			handleAuth(){
				if(this.info.name){
					return
				}else{
					uni.navigateTo({
						url:'/login/auth'
					})
				}
			},
			handleLogin(){
				uni.showModal({
					title: '提示',
					content: '是否确定退出登录',
					cancelColor:'#000000',
					confirmColor:'#FF8841',
					success: function (res) {
						if (res.confirm) {
							uni.removeStorageSync('token')
							uni.navigateTo({
								url:'/login/auth'
							})
						} else if (res.cancel) {
							// console.log('用户点击取消');
						}
					}
				});
			},
		}
	}
</script>

<style>
.mine{
	width: 100%;
	background: #F2F4F5;
	height: 100vh;
	/* background-color: #F2F4F5; */
}
.head{
	position: relative;
	z-index: 9;
	margin-top: -220rpx;
	padding-left: 40rpx;
	display: flex;
	align-items: center;
}
.head_con{
	margin-left: 24rpx;
}
.head_name{
	font-family: PingFangSC, PingFang SC;
	font-weight: 600;
	font-size: 36rpx;
	color: #333333;
}
.head_tips{
	font-family: PingFangSC, PingFang SC;
	font-weight: 400;
	font-size: 26rpx;
	color: #666666;
	margin-top: 10rpx;
}
.setup{
	margin: 0 24rpx;
	/* height: 234rpx; */
	background: #FFFFFF;
	border-radius: 16rpx;
	position: relative;
	z-index: 9;
	margin-top: 40rpx;
	padding: 28rpx 43rpx;
	box-sizing: border-box;
}
.setup_title{
	font-family: PingFangSC, PingFang SC;
	font-weight: 500;
	font-size: 32rpx;
	color: #333333;
}
.setup_li{
	display: flex;
	/* justify-content: ; */
	margin-top: 16rpx;
}
.setup_item{
	width: 25%;
	display: flex;
	align-items: center;
	flex-direction: column;
	justify-content: center;
	font-family: PingFangSC, PingFang SC;
	font-weight: 400;
	font-size: 26rpx;
	color: #666666;
}
.setup_item> image{
	width: 72rpx;
	margin-bottom: 14rpx;
}
.banner{
	width: 95%;
	margin: 0 auto;
	margin-top: 28rpx;
}
.num{
	font-family: PingFangSC, PingFang SC;
	font-weight: 400;
	font-size: 24rpx;
	color: #666666;
	text-align: center;
	margin-top: 26rpx;
}
</style>
